﻿using FDSimpleModelGenerator.Common.Enums;
using FDSimpleModelGenerator.IServices;

namespace FDSimpleModelGenerator.Services.Mappers
{
    /// <summary>
    /// Java语言类型转化服务
    /// </summary>
    public class JavaDataTypeMapperService : IDataTypeMapperService
    {
        public LanguageDataType LanguageDataType => LanguageDataType.Java;

        public string Map(string dbType, bool isUnsigned = false)
        {
            dbType = dbType.ToLower();
            switch (dbType)
            {
                case "int":
                case "integer":
                case "serial":
                    return "int";
                case "decimal":
                case "real":
                case "money":
                case "double precision":
                case "numeric":
                case "smallmoney":
                    return "double";
                case "bit":
                    return "boolean";
                case "bigint":
                case "bigserial":
                    return "long";
                case "float":
                    return "float";
                case "smallint":
                case "tinyint":
                    return "byte";
                case "smallserial":
                    return "ushort";
                case "datetime":
                case "datetime2":
                case "smalldatetime":
                case "time":
                case "date":
                    return "Date";
                case "nvarchar":
                case "varchar":
                case "char":
                default:
                    return "String";
            }
        }
    }
}
